﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.Xml;

namespace CarlowPitBoy
{
    class Animation
    {
        public Image imageSet;
        public Point imageDimensions;
        public bool[] affectedByMagic = new bool[10];//One for each magic power ???
        private PatternAlgorithm[,] patterns = new PatternAlgorithm[15,10];//15 Different animations can have up to 10 patterns each

        public Animation(Image imageSet, Point imageDimensions)
        {
            this.imageDimensions = imageDimensions;
            this.imageSet = imageSet;
        }

        private struct PatternAlgorithm
        {
            public Int16 fromFrame;
            public Int16 toFrame;
            public byte command;
            public Int16 frameRepeat;//N.B New! Decide how many frames each image should be shown
            public Int16 commandRepeat;

            /// <summary>
            /// The algorithm that will allow you to go through a series of Images and repeat previously occuring images, skip to a different frame or to force an end to the animation
            /// </summary>
            /// <param name="fromFrame">Starting frame for this pattern</param>
            /// <param name="toFrame">Ending frame for this pattern</param>
            /// <param name="command">Command that you wish to use - 0 is repeat fromFrame toFrame commandRepeat times, 1 is skip fromFrame toFrame commandRepeat times, 2 is to force end of algorithm</param>
            /// <param name="commandRepeat">How many times system will go back to fromFrame and repeat the process </param>
            public PatternAlgorithm(Int16 fromFrame, Int16 toFrame, byte command, Int16 frameRepeat, Int16 commandRepeat)
            {
                this.fromFrame = fromFrame;
                this.toFrame = toFrame;
                this.command = command;
                this.frameRepeat = frameRepeat;
                this.commandRepeat = commandRepeat;
            }
        }

        public void addPattern(string animationToAddTo, Int16 fromFrame, Int16 toFrame, byte command, Int16 frameRepeat, Int16 commandRepeat)
        {
            if (animationToAddTo == "Default")
            {
            }
            else if (animationToAddTo == "Fire")
            {
            }
            else if (animationToAddTo == "Water")//etc.
            {
            }
            else if (animationToAddTo == "Special Animation 1")
            {
            }
            else if (animationToAddTo == "Special Animation 2")
            {
            }
            else if (animationToAddTo == "Special Animation 3")
            {
            }
            else
            {
                MessageBox.Show("Error : Contact Manufacturer ; string sent to addPattern method in Animation.cs is invalid.", "Error : Incorrect String Read", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }

        public void save()
        {
        }

    }
}
